import { RoleType } from '../consts/resources';
import { BulletConfig } from '../game/config/bullet';

export const getRoleTypeByName = (name: string): RoleType => {
    if (name.startsWith('enemy')) {
        return RoleType.Enemy;
    } else if (name === 'player') {
        return RoleType.Player;
    } else if (name.startsWith('bullet')) {
        return RoleType.Bullet;
    }
    return RoleType.Other;
};

export const isBulletHit = (roleName: string, config: BulletConfig) => {
    for (let i = 0; i < config.targets.length; i++) {
        if (getRoleTypeByName(roleName) === config.targets[i]) {
            return true;
        }
    }
    return false;
};
